<?php
namespace PsiFramework\Classes\DAO\DAOInterface;

import("Classes.Model.Object");
import("Classes.Util.Database.Filters.QueryFilter");
import("Classes.Util.Database.Filters.Paginator");

use \PsiFramework\Classes\Model\Object;
use \PsiFramework\Classes\Util\Database\Filters\QueryFilter;
use \PsiFramework\Classes\Util\Database\Filters\Paginator;

/**
 * PsiFramework
 * Php Simple Framework
 *
 * @author Rémi San
 * @version beta
 */

/**
 * Interface des DAO
 *
 * @package DAO.Interface
 */
interface IDAO
{
    /**
     * Returns the ObjectParameters of the DAO
     * 
     * @return ObjectParameters
     */
    public function getObjectParameters();
    
    /**
     * The function to Retrieve the object using its primary key
     * 
     * @param mixed $key                 The key of the object
     * @param bool  $forceReloadFromBase Force the sql query ?
     * @param bool  $checkSecurity       Does the retrieve action
     *                                   need to check the security ?
     * 
     * @return Object
     */
    public function retrieveByPk(
        /*mixed*/ $key,
        /*bool*/ $forceReloadFromBase=false,
        /*bool*/ $checkSecurity=true
    );
    
    /**
     * The function to retrieve all the objects
     * 
     * @param QueryFilter $filter        The filter to apply
     * @param Paginator   $paginator     The paginator filter
     * @param bool        $checkSecurity Check the security ?
     * 
     * @return array
     */
    public function retrieveAll(
        QueryFilter $filter=null,
        Paginator   $paginator=null,
        /*bool*/    $checkSecurity=true
    );
    
    /**
     * The function to save an Object
     *
     * @param Object &$object            The object to save
     * @param bool   $performTransaction Does the save action
     *                                   need a transaction ?
     * @param bool   $checkSecurity      Does the save action
     *                                   need to check the security ?
     *
     * @see AbstractDAO::save()
     *
     * @return bool
     */
    public function save(
        Object   &$object,
        /*bool*/ $performTransaction=true,
        /*bool*/ $checkSecurity=true
    );
    
    /**
     * The function to delete an Object
     *
     * @param Object &$object            The object to delete
     * @param bool   $performTransaction Does the delete action
     *                                   need a transaction ?
     * @param bool   $checkSecurity      Does the delete action
     *                                   need to check the security ?
     *
     * @see AbstractDAO::delete()
     *
     * @return bool
     */
    public function delete(
        Object   &$object,
        /*bool*/ $performTransaction=true,
        /*bool*/ $checkSecurity=true
    );
    
}
